package demo.map;

import java.util.*;

/**
 * Version: 1.1
 * Author: TangJun
 * Date: 2024-07-23
 */
public class MapTest {
    public static void main(String[] args) {

        Map map = new HashMap();
        map.put(1, new Employee("李四", 20000, 1));
        map.put(1, new Employee("张三", 17000, 1));
        map.put(3, new Employee("李四", 20000, 3));
        map.put(4, new Employee("王五", 40000, 4));

        Set set1 = map.keySet();
        for (Object o : set1) {
            Employee obj = (Employee)map.get(o);
            if (obj.getSal() > 18000) {
                System.out.println(obj);
            }
        }

        Set set2 = map.entrySet();
        Iterator it = set2.iterator();
        while (it.hasNext()) {
            Map.Entry entry = (Map.Entry)it.next();
            Employee val = (Employee)entry.getValue();
            int key = (int)entry.getKey();
            if (val.getSal() > 18000) {

                System.out.println(key + "->" + val);
            }
        }
    }
}
